import tangled


class British(tangled.protocol.FramingProtocol):
    def connected(self):
        super(British, self).connected()
        self.counter = 0
    def on_frame(self, data):
        print data
        if self.counter > 10:
            return
        self.write("why i'm fine, and how do you do?")
        self.counter += 1

def client():
    b = British.connect("localhost", 12345)
    b.write("why hello there, how do you do?")
    return False

tangled.reactor.register_listener(British, port = 12345)
tangled.reactor.register_interval(1, client)
tangled.reactor.start()




